package com.framework.myBatis;

import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.HashMap;

public class QueryFilter extends HashMap<String ,Object> implements Serializable {

    public QueryFilter(){}
    public QueryFilter(HttpServletRequest request){
        Enumeration<String> attributeNames = request.getAttributeNames();
           while (attributeNames.hasMoreElements()){
               String attributeName = attributeNames.nextElement();
               String parameter = request.getParameter( attributeName );
               this.put( attributeName,parameter );
           }
    }

    public void setStatementKey(String statementKey){
        this.put( "statementKey",statementKey );
    }

    public String getStatement(){
        Object statementKey = this.get( "statementKey" );
        if(statementKey != null){
            if (statementKey instanceof  String){
                return (String) statementKey;
            }
        }
        return  null;
    }

    public void setStatementKey(String key,Object value){
        this.put(key,value );
    }
}
